package com.kedi.healthcenter.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kedi.healthcenter.read.dao.mapper.OldlifeMapper;
import com.kedi.healthcenter.service.OldlifeService;
import com.kedi.healthcenter.write.dao.mapper.OldLifeWriteMapper;
import org.springframework.transaction.annotation.Transactional;


/**
 * 
 *
 * @ClassName OldlifeServiceImpl
 * @author: 陈辽逊
 * @date: 2019/7/26 11:18
 */
@Service
public class OldlifeServiceImpl implements OldlifeService {

	@Autowired
	OldlifeMapper oldlifeMapper;
	@Autowired
	OldLifeWriteMapper oldlifeWriteMapper;

	final static Logger logger = LoggerFactory.getLogger(OldlifeServiceImpl.class);

	/**
	 * 查询全部床位信息
	 */
	@Override
	public List<Map<String, Object>> findBedList(int page,int limit) {
		try {
			List<Map<String, Object>> a = oldlifeMapper.findBedList(page,limit);
			return a;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("查询失败");
			return null;
		}
	}

	/**
	 * 根据价格返回床位信息
	 */
	@Override
	public List<Map<String, Object>> oldprice(int minprice, int maxprice,int page,int limit) {
		try {
			List<Map<String, Object>> a = oldlifeMapper.oldprice(minprice, maxprice,page,limit);
			return a;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("查询失败");
			return null;
		}
	}

	/**
	* 方法实现说明  养老院点赞
	* @author      ytw
	*@param			map
	* @return
	* @exception
	* @date        2019/7/31 20:38
	*/
	@Transactional(rollbackFor=Exception.class)
	 @Override
    public int updatePraise(Map map) {

		 oldlifeWriteMapper.updatePraise( Integer.parseInt(map.get("oldlife_id").toString()) );
		 return oldlifeWriteMapper.createpraise(map);
    }


    /**
    * 方法实现说明  养老院收藏
    * @author      ytw
    *@param			map
    * @return
    * @exception
    * @date        2019/7/31 20:38
    */
	@Transactional(rollbackFor=Exception.class)
    @Override
    public int updateCollection(Map map) {

		oldlifeWriteMapper.updateCollection(map);
		return oldlifeWriteMapper.createcolection(map);
    }

}
